package com.sskj.lib.util;

import android.widget.TextView;

import com.sskj.common.base.App;
import com.sskj.common.util.TimeUtil;
import com.sskj.lib.R;
import com.trello.rxlifecycle2.LifecycleProvider;

import io.reactivex.disposables.Disposable;

public class SendCodeUtil {
    public static Disposable timeCount(LifecycleProvider lifecycleProvider, TextView tvGetCheckCode){
        return TimeUtil.newTime(lifecycleProvider)
                .subscribe(aLong -> {
                    if (aLong > 0) {
                        tvGetCheckCode.setText(aLong + "s");
                    } else {
                        tvGetCheckCode.setText(App.INSTANCE.getString(R.string.lib_sendCodeUtil1));
                        tvGetCheckCode.setEnabled(true);
                    }
                });
    }
}
